const express = require("express");
const app = express();
const PORT = 3000;
const cors = require("cors");
var bodyParser = require("body-parser");
app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
// 使用 CORS 中间件处理跨域请求
app.use(cors());
const dataRouter = require("./router/index");

// 解析请求体中的 JSON 数据
app.use(express.static("../client"));
app.use(express.json());

// 使用路由处理程序
app.use("/", dataRouter);

// 启动服务器
app.listen(PORT, () => {
  console.log(`Server is running on http://localhost:${PORT}`);
});
